package com.link2room.optimus.controller.api;

import com.link2room.common.dto.result.base.BaseResultDto;
import com.link2room.optimus.dto.param.api.BookStockApiParamDto;
import com.link2room.optimus.dto.result.api.BookStockApiDto;
import com.link2room.optimus.facade.IMarketingApiFacadeService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Created by sss on 2016/9/19.
 */
@Api(tags = "活动明细")
@RestController
@RequestMapping("/api/MarketingDetails")
public class MarketingDetailApiController {
    @Resource
    private IMarketingApiFacadeService marketingApiFacadeService;

    @RequestMapping(value = "/{id}",method = RequestMethod.GET)
    public BaseResultDto bookStocks(
            @PathVariable Long id,
            @RequestParam(value = "checkInDatetime" ,required = true) String checkInDatetime,
            @RequestParam(value = "checkOutDatetime" ,required = true) String checkOutDatetime,
            @RequestParam(value = "rmNum" ,required = false) Integer rmNum
    ) throws Exception {
        BookStockApiParamDto bookStockParamDto=new BookStockApiParamDto();
        bookStockParamDto.setId(id);
        bookStockParamDto.setCheckInDatetime(checkInDatetime);
        bookStockParamDto.setCheckOutDatetime(checkOutDatetime);
        if(rmNum==null){
            rmNum=1;
        }
        bookStockParamDto.setRmNum(rmNum);
        BookStockApiDto bookStockApiDto = marketingApiFacadeService.checkBookStock(bookStockParamDto);
        BaseResultDto l2rRs=new BaseResultDto();
        l2rRs.setResultCode(0);
        l2rRs.setResultInfo(bookStockApiDto);
        return l2rRs;
    }
}
